import 'package:flutter/material.dart';

class CustomPageController extends PageController {
  CustomPageController({
    super.initialPage = 0,
    super.viewportFraction = 1.0,
    super.keepPage = true,
  });

  bool _isAnimating = false;

  Future<void> animateToNextPage() async {
    if (_isAnimating) return;
    _isAnimating = true;
    
    await animateToPage(
      page!.round() + 1,
      duration: const Duration(milliseconds: 300),
      curve: Curves.easeInOut,
    );
    
    _isAnimating = false;
  }

  Future<void> animateToPreviousPage() async {
    if (_isAnimating || page!.round() <= 0) return;
    _isAnimating = true;
    
    await animateToPage(
      page!.round() - 1,
      duration: const Duration(milliseconds: 300),
      curve: Curves.easeInOut,
    );
    
    _isAnimating = false;
  }
}
